﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using RenAi.Medical.BLL;
using RenAi.Medical.Model;

namespace RenAi.Medical.Admin
{
    public partial class UpdAnswer1 : System.Web.UI.Page
    {
        AnswerBLL bll = new AnswerBLL();
        ProblemBLL bll1 = new ProblemBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                if(Request.QueryString["id"]!=null)
                {
                    this.txtAid.Text = Request.QueryString["id"].ToString();
                    LoadDoctor();
                    LoadAnswer();
                }
            }
        }
        public void LoadDoctor()
        {
            this.DropDownList1.DataSource = bll.ShowDoctor();
            this.DropDownList1.DataValueField = "Doctor_Id";
            this.DropDownList1.DataTextField = "Doctor_Name";
            this.DropDownList1.DataBind();
        }
        public void LoadAnswer()
        {
            DataTable dt = bll.GetAnswer(this.txtAid.Text);
            this.txtcontent.Text = dt.Rows[0][1].ToString();
            this.DropDownList1.SelectedValue = dt.Rows[0][2].ToString();
        }
        protected void btnUpd_Click(object sender, EventArgs e)
        {
            Answer a = new Answer();
            a.Doctor_Id = int.Parse(this.DropDownList1.SelectedValue);
            a.Aid = int.Parse(this.txtAid.Text);
            a.Acontent = this.txtcontent.Text;
            if(bll.UpdAnswer(a)>0)
            {
                Response.Write("<script>alert('修改成功!')</script>");
            }
            

        }

        protected void btnBack_Click(object sender, EventArgs e)
        {
            Response.Redirect("huida.aspx");
        }
    }
}